// 导入路由依赖
import { useRoutes } from 'react-router-dom';
import { UserOutlined } from '@ant-design/icons';
// import Private from '@/router/Private.tsx';
import LazyLoad from '@/router/LazyLoad.tsx';
import { lazy } from 'react';
import { BaseLayout, BlankLayout } from '@/layouts/index.tsx';
// 导入页面
const Login: any = lazy(() => import('../views/login/index.tsx'));
const Home = LazyLoad('../views/home/index.tsx');
const RoleView = LazyLoad('../views/system/role/index.tsx');

// 创建路由
export const routes_list: any = [
	{
		path: '/',
		key: '/',
		label: '首页',
		element: <BaseLayout/>,
		children: [
			{
				path: '/index',
				key: 'index',
				label: '首页',
				element: Home
			}
		]
	},
	{
		path: '/system',
		key: 'system',
		label: '系统管理',
		icon: <UserOutlined />,
		element: <BaseLayout/>,
		children: [
			{
				path: 'role',
				key: 'role',
				label: '角色管理',
				element: RoleView
			}
		]
	},
	{
		path: '/goodsManage',
		key: 'goodsManage',
		label: '商品管理',
		icon: <UserOutlined />,
		element: <BaseLayout/>,
		children: [
			{
				path: 'goodsList',
				key: 'goodsList',
				label: '商品列表',
				element: <BlankLayout />,
				children: [
					{
						path: 'goodsU',
						key: 'goodsU',
						label: '商品列表',
						element: RoleView
					}
				]
			}
		]
	}
];
const otherRouter = [
	{
		path: '/user',
		key: 'user',
		label: '用户',
		element: <BlankLayout />,
		children: [
			{
				path: 'login',
				key: 'login',
				label: '用户登录',
				element: <Login />
			}
		]
	},
	// 配置404页面
	{
		path: '*',
		hidden: true,
		element: LazyLoad('../views/NoMatch.tsx')
	}
];
// 使用useRoutes 创建
export default function RouterView() {
	// 创建路由
	const elem = useRoutes(routes_list.concat(otherRouter));
	// 返回接口
	return elem;
}
